/****************************************
 ****************************************
 **   This document written by CTonk.  **
 **        ctonk87@hotmail.com         **
 ****************************************
 ****************************************/

// commands.cpp

#ifndef CPP_COMMANDS
#define CPP_COMMANDS

#include "commands.h"

// Keep everything in this file in alphabetical order, it's tons easier.
DEF_COMMAND( CmdAlist );
DEF_COMMAND( CmdCommands );
DEF_COMMAND( CmdCredits );
DEF_COMMAND( CmdDisconnect ); // FIXME!!
DEF_COMMAND( CmdDisplay ); // Just for debugging.
DEF_COMMAND( CmdDown );
DEF_COMMAND( CmdDrop ); // ADD!!
DEF_COMMAND( CmdEast );
DEF_COMMAND( CmdExits );
DEF_COMMAND( CmdGecho );
DEF_COMMAND( CmdGet );
DEF_COMMAND( CmdGossip );
DEF_COMMAND( CmdGoto );
DEF_COMMAND( CmdHelp );
DEF_COMMAND( CmdInformation );
DEF_COMMAND( CmdInventory );
DEF_COMMAND( CmdLook );
DEF_COMMAND( CmdNorth );
DEF_COMMAND( CmdQuit );
DEF_COMMAND( CmdReload );
DEF_COMMAND( CmdRules );
DEF_COMMAND( CmdSave );
DEF_COMMAND( CmdSay );
DEF_COMMAND( CmdScore );
DEF_COMMAND( CmdShutdown );
DEF_COMMAND( CmdSockets );
DEF_COMMAND( CmdSouth );
DEF_COMMAND( CmdTell );
DEF_COMMAND( CmdTime );
DEF_COMMAND( CmdUp );
DEF_COMMAND( CmdWest );
DEF_COMMAND( CmdWho );
DEF_COMMAND( CmdWhos );
DEF_COMMAND( CmdNull ); // Used for command searching and debugging only

CmdAlist::CmdAlist() {
	SetName( "alist" );
	SetGroup( "player" );
	SetEnabled( true );
}

bool CmdAlist::Execute( Character* ch, const std::string& args ) {
	Area* area = 0;
	std::string buf;

	buf = "Area List:\n\n";
	buf << "{xName, {yKeyword{x, {CSize{x, {WPermissions{x\n";

	for ( int x=0; x < World::Instance().GetAreas().GetSize(); x++ ) {
		area = World::Instance().GetArea( x );
		buf << "\n{x" << area->GetName()
			<< "  {y" << area->GetKeyword()
			<< "  {C" << area->GetSize()
			<< "  {W" << "1 23 74";
	}

	ch->Send( buf );

	return true;
}

CmdCommands::CmdCommands() {
	SetName( "commands" );
	SetGroup( "player" );
	SetEnabled( true );
}

bool CmdCommands::Execute( Character* ch, const std::string& args ) {
	Command* cmd;
	std::string buf;
	int x=1;

	buf << (int)CmdList.size()-1 << " commands in all...\n";

	for ( std::list< Command* >::iterator CMD = CmdList.begin(); CMD != CmdList.end(); CMD++ ) 	{
		cmd = *(CMD);

		if ( (x-1)%4 != 0 )
			if ( cmd->_name.length() < 8 )
				buf << "\t\t";
			else
				buf << '\t';
		buf << cmd->_name;
		if ( x%4 == 0 )
			buf << "\n";
		x++;
	}

	buf << "\n";

	ch->Send( buf );

	return true;
}

CmdCredits::CmdCredits() {
	SetName( "credits" );
	SetGroup( "player" );
	SetEnabled( true );
}

bool CmdCredits::Execute( Character* ch, const std::string& args ) {
	std::string buf;

	buf << "I'd like to thank the following people for aid in the development of this game:\n\n";
	buf << "{W-{xRendelven, who supplied the basic socket/server code from his \"Scratch MUD\".\n";
	buf << "{W-{xDamacus for his creativity... because I possess none of my own.\n";
	buf << "{W-{xMelchiah, my assistant coder.\n";
	buf << "{W-{xKemintari, for the wonderful website.\n";
	buf << "{W-{xZantix, who is more dedicated to Symphony (and its areas) then I am.\n";
	buf << "{W-{xStewart Gilligan Griffin, my inspiration.\n";

	ch->Send( buf );

	return true;
}



CmdDisconnect::CmdDisconnect() {
	SetName( "disconnect" );
	SetGroup( "head" );
	SetEnabled( true );
}

bool CmdDisconnect::Execute( Character* ch, const std::string& args ) {
	Character* it;
	std::string target;
	std::string buf;
	std::string buf2;

	split( args, target );

	if ( target.empty() ) 	{
		buf << "syntax: disconnect <target>\n";
		return true;
	}

	for ( int x=0; x < ChList.GetSize(); x++ ) {
		it = ChList[x];
		if ( it->GetName() == target ) {
			buf2 << "\nYou've been disconnected!\n";
			it->Send( buf2 );
			it->SetConnected( false );
			buf << '\n' << it->GetName();
			buf << " has been disconnected!\n";
			return true;
		}
	}

	ch->Send( buf );
	return false;
}

CmdDisplay::CmdDisplay() {
	SetName( "display" );
	SetGroup( "player" );
	SetEnabled( true );
}

bool CmdDisplay::Execute( Character* ch, const std::string& args ) {
	std::string buf;
	Area* area;
	Room* room;

	for ( int x=0; x < World::Instance().GetAreas().GetSize(); x++ ) {
		area = World::Instance().GetArea( x );

		area->Display( buf );
		buf << '\n';

        for ( int y=0; y < area->GetSize(); y++ ) {
            room = area->GetRoom( y );
			room->Display( buf );
			buf << '\n';
		}
	}

	ch->Send( buf );

	return true;
}

CmdDown::CmdDown() {
	SetName( "down" );
	SetShortcut( "d" );
	SetGroup( "player" );
	SetEnabled( true );
}

bool CmdDown::Execute( Creature* ch, const std::string& args ) {
	std::string buf;
	Exit* in = &( ch->GetRoom()->GetExit( DOWN ) );
	
	if ( !in->GetThere() ) {
		buf << "There is no exit that way.\n";
		ch->Send( buf );
		return true;
	}
	else if ( in->GetDoor() && !in->GetOpen() ) {
		buf << "That door is closed.\n";
		ch->Send( buf );
		return true;
	}
	else {
		Room* from = ch->GetRoom();
		Room* to = World::Instance().FindRoom( in->GetPoint() );

		to->Add( ch );
		from->Remove( ch );
		ch->SetRoom( World::Instance().FindRoom( to->GetVnum() )->GetVnum() );
		CmdLook Command;
		Command.Execute( ch, "auto_look: down" );
	}

	return true;
}

CmdDrop::CmdDrop() {
	SetName( "drop" );
	SetGroup( "player" );
	SetEnabled( true );
}

bool CmdDrop::Execute( Character* ch, const std::string& args ) {
	std::string buf;
	Room* room = ch->GetRoom();
	Object* obj = 0;

	parse( args.data() );

	for ( int x=0; x < ch->GetInventory().GetSize(); x++ ) {
		obj = ch->GetInventory()[x];
		if ( same( obj->GetName(), arg[1] ) ) {
			ch->Remove( obj );
			room->Add( obj );
			buf << "You drop " << obj->GetShort() << ".";
			ch->Send( buf );
			return true;
		}
	}

	buf << "You don't posess that item.";
	ch->Send( buf );

	return true;
}

CmdEast::CmdEast() {
	SetName( "east" );
	SetShortcut( "e" );
	SetGroup( "player" );
	SetEnabled( true );
}

bool CmdEast::Execute( Character* ch, const std::string& args ) {
	std::string buf;
	Exit* in = &( ch->GetRoom()->GetExit( EAST ) );
	
	if ( !in->GetThere() ) {
		buf << "There is no exit that way.\n";
		ch->Send( buf );
		return true;
	}
	else if ( in->GetDoor() && !in->GetOpen() ) {
		buf << "That door is closed.\n";
		ch->Send( buf );
		return true;
	}
	else {
		Room* from = ch->GetRoom();
		Room* to = World::Instance().FindRoom( in->GetPoint() );

		to->Add( ch );
		from->Remove( ch );
		ch->SetRoom( World::Instance().FindRoom( to->GetVnum() )->GetVnum() );
		CmdLook Command;
		Command.Execute( ch, "auto_look: east" );
	}

	return true;
}


CmdExits::CmdExits() {
	SetName( "exits" );
	SetGroup( "player" );
	SetEnabled( true );
}

bool CmdExits::Execute( Character* ch, const std::string& args) {
	std::string buf;
	bool hits = false;
	Room* room = ch->GetRoom();

	buf << "Exits: [ ";
	for ( int x=0; x < 6; x++ ) {
		if ( room->GetExit( x ).GetThere() ) {
			hits = true;
			buf << Exit::StringName( x ) << ' ';
		}
	}

	if ( !hits )
		buf << "none ";
	buf << "]\n";

	ch->Send( buf );
	return true;
}


CmdGecho::CmdGecho() {
	SetName( "gecho" );
	SetShortcut( "god" );
	SetGroup( "player" );
	SetEnabled( true );
}

bool CmdGecho::Execute( Character* ch, const std::string& args ) {
	std::string buf;

	parse( args.data() );
	split( input );
	buf << '{' << ch->GetEchocolor() << input << "{x";

	for ( int x=0; x < ChList.GetSize(); x++ )
		ChList[x]->Send( buf );

	return true;
}

CmdGet::CmdGet() {
	SetName( "get" );
	SetShortcut( "g" );
	SetGroup( "player" );
	SetEnabled( true );
}

bool CmdGet::Execute( Character* ch, const std::string& args ) {
	std::string buf;
	Room* room = ch->GetRoom();
	Object* obj = 0;
	parse( args.data() );

	for ( int x=0; x < room->GetOlist().GetSize(); x++ ) {
		obj = room->GetO( x );
		if ( same( obj->GetName(), arg[1] ) ) {
			ch->Add( obj );
			room->Remove( obj );
			buf << "You get " << obj->GetShort() << ".";
			ch->SetWeight( ch->GetWeight() + obj->GetWeight() );
			ch->Send( buf );		
			return true;
		}
	}

	buf << "You don't see that item here.";
	ch->Send( buf );

	return true;
}

CmdGossip::CmdGossip() {
	SetName( "gossip" );
	SetShortcut( "." );
	SetGroup( "player" );
	SetEnabled( true );
}

bool CmdGossip::Execute( Character* ch, const std::string& crapola ) {

	Creature* c2 = 0;
	std::string buf;
	char* temp = new char[MAX_INPUT_BUFFER];
	char* t2 = new char[MAX_INPUT_BUFFER];

	strcpy( temp, crapola.c_str() );

	strcpy( temp, split( temp ) );
	ltrim( temp );
	rtrim( temp );

	buf << "You gossip \'{c" << temp << "{x\'\n";
	ch->Send( buf );

	for ( int x=0; x < ChList.GetSize(); x++ ) {
		c2 = ChList[x];
		if ( c2 == ch )
			continue;
		buf = ch->GetName();
		buf << " gossips \'{c" << temp << "{x\'\n";
		c2->Send( buf );
	}

	return true;
}

CmdGoto::CmdGoto() {
	SetName( "goto" );
	SetGroup( "player" );
	SetEnabled( true );
}

bool CmdGoto::Execute( Character* ch, const std::string& args ) {
	
	char* temp = new char[MAX_INPUT_BUFFER];
	strcpy( temp, args.c_str() );
	parse( temp );

	int to = atoi( arg[1] );

	ch->GetRoom()->Remove( ch );
	World::Instance().FindRoom( to )->Add( ch );
	ch->SetRoom( World::Instance().FindRoom( to )->GetVnum() );
	Command* cmd = new CmdLook;
	cmd->Execute( ch, args );
	delete cmd;

	return true;
}

CmdHelp::CmdHelp() {
	SetName( "help" );
	SetShortcut( "?" );
	SetGroup( "player" );
	SetEnabled( true );
}

bool CmdHelp::Execute( Character* ch, const std::string& args ) {
	std::string buf;

	buf << "No help yet; try typing \"commands\".\n";

	ch->Send( buf );

	return true;
}

CmdInformation::CmdInformation() {
	SetName( "information" );
	SetShortcut( "info" );
	SetGroup( "player" );
	SetEnabled( true );
}

bool CmdInformation::Execute( Character* ch, const std::string& args ) {
	std::string buf;
	int temp = 0;
	int commands = 0, areas = 0, rooms = 0, exits = 0, objects = 0, connections = 0;
	Area* area = 0;
	Room* room = 0;

	commands = (int)CmdList.size()-1;
	areas = World::Instance().GetAreas().GetSize();
	for ( int x=0; x < areas; x++ ) {
		area = World::Instance().GetArea( x );
		for ( int y=0; y < area->GetSize(); y++ ) {
			rooms++;
			room = area->GetRoom( y );
			for ( int z=0; z < 6; z++ )
				if ( room->GetExit( z ).GetThere() )
					exits++;
		}
		objects += area->GetObjects().GetSize();
	}
	connections = ChList.GetSize();

	buf << "  Current available information...";
	buf << "\n{x\tVersion:     {W" << World::Instance().Version();
	buf << "\n{x\tCommands:    {W" << commands;
	buf << "\n{x\tAreas:       {W" << areas;
	buf << "\n{x\tRooms:       {W" << rooms;
	buf << "\n{x\tExits:       {W" << exits;
	buf << "\n{x\tObjects:     {W" << objects;
	buf << "\n{x\tConnections: {W" << connections;

	ch->Send( buf );

	return true;
}

CmdInventory::CmdInventory() {
	SetName( "inventory" );
	SetShortcut( "inv" );
	SetGroup( "player" );
	SetEnabled( true );
}

bool CmdInventory::Execute( Character* ch, const std::string& args ) {
	std::string buf;

	if ( ch->GetInventory().GetSize() == 0 )
		buf << "You hold nothing in your inventory.\n";
	else {
		buf << "You look at your inventory.\n";
		for ( int x=0; x < ch->GetInventory().GetSize(); x++ )
			buf << '\t' << ch->GetObject( x )->GetShort() << '\n';
	}
    
	ch->Send( buf );

	return true;
}

CmdLook::CmdLook() {
	SetName( "look" );
	SetShortcut( "l" );
	SetGroup( "player" );
	SetEnabled( true );
}

bool CmdLook::Execute( Character* ch, const std::string& args ) {
	std::string buf;
	Creature* tempc;
	Room* room = ch->GetRoom();

	buf << "\n\n{g" << room->GetName() << "{x" << " [ {y" << room->GetVnum() << "{x ]\n";
	buf << room->GetDescolor() << room->GetDesc() << "{x\nExits: {B[ {W";
	if ( room->NoExits() )
		buf << "{Rnone{x ";
	else
		for ( int x=0; x < 6; x++ )
			if ( room->GetExit( x ).GetThere() )
				buf << Exit::StringName( x ) << ' ';

	buf << "{B]{x\n";
	buf << "  Some people are here randomly.\n";

	for ( int x=0; x < ch->GetRoom()->GetClist().GetSize(); x++ ) {
		tempc = ch->GetRoom()->GetC( x );
		if ( tempc == ch )
			continue;
		buf << "  " << tempc->GetName() << " is here mocking you.\n";
	}

	for ( int x=0; x < ch->GetRoom()->GetOlist().GetSize(); x++ )
		buf << "  " << ch->GetRoom()->GetO( x )->GetLong() << '\n';


	ch->Send( buf );

	return true;
}

CmdNorth::CmdNorth() {
	SetName( "north" );
	SetShortcut( "n" );
	SetGroup( "player" );
	SetEnabled( true );
}

bool CmdNorth::Execute( Character* ch, const std::string& args ) {
	std::string buf;
	Exit* in = &( ch->GetRoom()->GetExit( NORTH ) );
	
	if ( !in->GetThere() ) {
		buf << "There is no exit that way.\n";
		ch->Send( buf );
		return true;
	}
	else if ( in->GetDoor() && !in->GetOpen() ) {
		buf << "That door is closed.\n";
		ch->Send( buf );
		return true;
	}
	else {
		Room* from = ch->GetRoom();
		Room* to = World::Instance().FindRoom( in->GetPoint() );

		to->Add( ch );
		from->Remove( ch );
		ch->SetRoom( World::Instance().FindRoom( to->GetVnum() )->GetVnum() );
		CmdLook Command;
		Command.Execute( ch, "auto_look: north" );
	}

	return true;
}

CmdQuit::CmdQuit() {
	SetName( "quit" );
	SetGroup( "player" );
	SetEnabled( true );
}

bool CmdQuit::Execute( Character* ch, const std::string& args ) {
	std::string buf;
	buf << "\n" << World::Instance().RandomQuote() << "\n\n";

	ch->Send( buf );
	ch->SetConnected( false );

	return true;
}

CmdReload::CmdReload() {
	SetName( "reload" );
	SetGroup( "player" );
	SetEnabled( true );
}

bool CmdReload::Execute( Character* ch, const std::string& args ) {
	World::Instance().GetAreas().Purge();
	World::Instance().Load();
	ch->Send( "done" );

	return true;
}

CmdRules::CmdRules() {
	SetName( "rules" );
	SetGroup( "player" );
	SetEnabled( true );
}

bool CmdRules::Execute( Character* ch, const std::string& args ) {
	std::string buf;

	buf << "You are {Rwrong{x, Xantiloth is right.\n";

	ch->Send( buf );

	return true;
}

CmdSave::CmdSave() {
	SetName( "save" );
	SetGroup( "player" );
	SetEnabled( true );
}

bool CmdSave::Execute( Character* ch, const std::string& args ) {
	std::string buf;

	ch->Save();
	World::Instance().Save();

	buf << "{cYour information has successfully been saved.\n";

	ch->Send( buf );

	buf = "Saved. Input: " + args;
	log( ch, buf );

	return true;
}

CmdSay::CmdSay() {
	SetName( "say" );
	SetShortcut( "," );
	SetGroup( "player" );
	SetEnabled( true );
}

bool CmdSay::Execute( Character* ch, const std::string& args ) {
	Creature* c2 = 0;
	std::string buf;
	char* temp = new char[MAX_INPUT_BUFFER];
	char* t2 = new char[MAX_INPUT_BUFFER];

	strcpy( temp, args.c_str() );

	strcpy( temp, split( temp ) );
	ltrim( temp );
	rtrim( temp );

	buf << "You say \'{G" << temp << "{x\'\n";
	ch->Send( buf );

	for ( int x=0; x < ChList.GetSize(); x++ ) {
		c2 = ChList[x];
		if ( c2 != ch && c2->GetRoom()->GetVnum() == ch->GetRoom()->GetVnum() ) {
            buf = ch->GetName();
			buf << " says \'{G" << temp << "{x\'\n";
			c2->Send( buf );
		}
	}

	return true;
}

CmdScore::CmdScore() {
	SetName( "score" );
	SetShortcut( "sc" );
	SetGroup( "player" );
	SetEnabled( true );
}

bool CmdScore::Execute( Character* ch, const std::string& args ) {
	std::string buf;

	ch->Display( buf );
	ch->Send( buf );

	return true;
}

CmdShutdown::CmdShutdown() {
	SetName( "shutdown" );
	SetGroup( "head" );
	SetEnabled( true );
}

bool CmdShutdown::Execute( Character* ch, const std::string& args ) {
	std::string buf;

	cout << "Symphony shutting down...\n";
	buf << "Symphony shutting down...\n";

	ch->Send( buf );

	buf = "Shutdown the server. Input: " + args;
	log( ch, buf );

	buf = ch->GetName();
	buf << " @ (" << ch->GetSocket()->GetSocketIP() << ' '
		<< ch->GetSocket()->GetDescriptor()
		<< ") Shutdown the server. Input: " << args;
	log( server, buf );

	World::Instance()._exists = false;
	return true;
}

CmdSockets::CmdSockets( ) {
	SetName( "sockets" );
	SetGroup( "imm" );
	SetEnabled( true );
}

bool CmdSockets::Execute( Character* ch, const string& args ) {
	std::string buf;

	buf << "\t{w--{x== {WSockets {x=={w--{x\n";

    for ( int x=0; x < ChList.GetSize(); x++ ) {
		ch = ChList[x];
		buf << "  {W" << ch->GetName() << "{x: {C" << ch->GetSocket()->GetSocketIP()
			<< " {w(descriptor: " << ch->GetSocket()->GetDescriptor() << ")\n\r";
	}
	ch->Send( buf );
	return true;
}

CmdSouth::CmdSouth() {
	SetName( "south" );
	SetShortcut( "s" );
	SetGroup( "player" );
	SetEnabled( true );
}

bool CmdSouth::Execute( Character* ch, const std::string& args ) {
	std::string buf;
	Exit* in = &( ch->GetRoom()->GetExit( SOUTH ) );
	
	if ( !in->GetThere() ) {
		buf << "There is no exit that way.\n";
		ch->Send( buf );
		return true;
	}
	else if ( in->GetDoor() && !in->GetOpen() ) {
		buf << "That door is closed.\n";
		ch->Send( buf );
		return true;
	}
	else {
		Room* from = ch->GetRoom();
		Room* to = World::Instance().FindRoom( in->GetPoint() );

		to->Add( ch );
		from->Remove( ch );
		ch->SetRoom( World::Instance().FindRoom( to->GetVnum() )->GetVnum() );
		CmdLook Command;
		Command.Execute( ch, "auto_look: south" );
	}

	return true;
}

CmdTell::CmdTell() {
	SetName( "tell" );
	SetGroup( "player" );
	SetEnabled( true );
}

bool CmdTell::Execute( Character* ch, const std::string& args ) {
	bool found = false;
	std::string buf;
	Creature* c2 = 0;

	char* temp = new char[MAX_INPUT_BUFFER];
	init( temp );

	parse( temp );
	char* to = new char[100];
	strcpy( to, arg[1] );

	// Split twice because we have to get rid of the command and the target.
	split( temp );
	split( temp );
	rtrim( temp );
	ltrim( temp );

	// Is ch attempting to converse with himself/herself?
	if ( same( ch->GetName(), to ) ) {
		buf = "You make the mental note: \"{Y";
		buf << temp << "{x\"";
		ch->Send( temp );
		return true;
	}

	for ( int x=0; x < ChList.GetSize(); x++ ) {
		c2 = ChList[x];
		if ( same( c2->GetName(), to ) ) {
			found = true;
			break;
		}
	}

	if ( found ) {
		buf = "You tell ";
		buf << c2->GetName() << " \"{Y" << temp << "{x\"";
		ch->Send( buf );
		buf = ch->GetName();
		buf << " tells you \"{Y" << temp << "{x\"";
		c2->Send( buf );
	}
	else {
		buf = "They aren't here right now.";		
		ch->Send( buf );
	}

	return true;
}


CmdTime::CmdTime() {
	SetName( "time" );
	SetGroup( "player" );
	SetEnabled( true );
}

bool CmdTime::Execute( Character* ch, const std::string& args ) {
	std::string buf;

	buf << "Server Date:  " << World::Instance().GetClock()->GetDate();
	buf << "\nServer Time:  " << World::Instance().GetClock()->GetTime() << '\n';

	ch->Send( buf );

	return true;
}

CmdUp::CmdUp() {
	SetName( "up" );
	SetShortcut( "u" );
	SetGroup( "player" );
	SetEnabled( true );
}

bool CmdUp::Execute( Character* ch, const std::string& args ) {
	std::string buf;
	Exit* in = &( ch->GetRoom()->GetExit( UP ) );
	
	if ( !in->GetThere() ) {
		buf << "There is no exit that way.\n";
		ch->Send( buf );
		return true;
	}
	else if ( in->GetDoor() && !in->GetOpen() ) {
		buf << "That door is closed.\n";
		ch->Send( buf );
		return true;
	}
	else {
		Room* from = ch->GetRoom();
		Room* to = World::Instance().FindRoom( in->GetPoint() );

		to->Add( ch );
		from->Remove( ch );
		ch->SetRoom( World::Instance().FindRoom( to->GetVnum() )->GetVnum() );
		CmdLook Command;
		Command.Execute( ch, "auto_look: up" );
	}

	return true;
}

CmdWest::CmdWest() {
	SetName( "west" );
	SetShortcut( "w" );
	SetGroup( "player" );
	SetEnabled( true );
}

bool CmdWest::Execute( Character* ch, const std::string& args ) {
	std::string buf;
	Exit* in = &( ch->GetRoom()->GetExit( WEST ) );
	
	if ( !in->GetThere() ) {
		buf << "There is no exit that way.\n";
		ch->Send( buf );
		return true;
	}
	else if ( in->GetDoor() && !in->GetOpen() ) {
		buf << "That door is closed.\n";
		ch->Send( buf );
		return true;
	}
	else {
		Room* from = ch->GetRoom();
		Room* to = World::Instance().FindRoom( in->GetPoint() );

		to->Add( ch );
		from->Remove( ch );
		ch->SetRoom( World::Instance().FindRoom( to->GetVnum() )->GetVnum() );
		CmdLook Command;
		Command.Execute( ch, "auto_look: west" );
	}

	return true;
}

CmdWho::CmdWho() {
	SetName( "who" );
	SetGroup( "player" );
	SetEnabled( true );
}

bool CmdWho::Execute( Character* ch, const std::string& args ) {
	Character* it;
	std::string buf;

	buf << " {WKingdom of Legends Population...{x\n";

	for ( int x=0; x < ChList.GetSize(); x++ ) {
		it = ChList[x];
		buf << "  " << it->GetName() << "\n";
	}

	ch->Send( buf );
	return true;
}

CmdWhos::CmdWhos() {
	SetName( "whos" );
	SetGroup( "imm" );
	SetEnabled( true );
}

bool CmdWhos::Execute( Character* ch, const std::string& args ) {
	Character* it;
	std::string buf;

	buf << " {WModified Population List...{x\n";

	for ( int x=0; x < ChList.GetSize(); x++ ) {
		it = ChList[x];
		buf << "  {x" << it->GetName() <<  ":\t{C" << it->GetSocket()->GetSocketIP()
			<< "  {w" << it->GetSocket()->GetDescriptor() << "\n";
	}

	ch->Send( buf );
	return true;
}

CmdNull::CmdNull() {
	SetName( "cmdnull" );
	SetGroup( "player" );
	SetEnabled( true );
}

bool CmdNull::Execute( Character* ch, const std::string& args ) {
	ch->Send( "Huh?\n" );
	return true;
}






void World::InitializeCommands() {
	// Adds commands into the main compiled list; if it's not here, it won't exist!
	CmdList.push_back( new CmdAlist );
	CmdList.push_back( new CmdCommands );
	CmdList.push_back( new CmdCredits );
	CmdList.push_back( new CmdDisconnect );
	CmdList.push_back( new CmdDisplay );
	CmdList.push_back( new CmdDown );
	CmdList.push_back( new CmdDrop );
	CmdList.push_back( new CmdEast );
	CmdList.push_back( new CmdExits );
	CmdList.push_back( new CmdGecho );
	CmdList.push_back( new CmdGet );
	CmdList.push_back( new CmdGossip );
	CmdList.push_back( new CmdGoto );
	CmdList.push_back( new CmdHelp );
	CmdList.push_back( new CmdInformation );
	CmdList.push_back( new CmdInventory );
	CmdList.push_back( new CmdLook );
	CmdList.push_back( new CmdNorth );
	CmdList.push_back( new CmdQuit );
	CmdList.push_back( new CmdReload );
	CmdList.push_back( new CmdRules );
	CmdList.push_back( new CmdSay );
	CmdList.push_back( new CmdSave );
	CmdList.push_back( new CmdScore );
	CmdList.push_back( new CmdShutdown );
	CmdList.push_back( new CmdSockets );
	CmdList.push_back( new CmdSouth );
	CmdList.push_back( new CmdTell );
	CmdList.push_back( new CmdTime );
	CmdList.push_back( new CmdUp );
	CmdList.push_back( new CmdWest );
	CmdList.push_back( new CmdWho );
	CmdList.push_back( new CmdWhos );
	CmdList.push_back( new CmdNull );

	return;
}




#endif // #ifndef CPP_COMMANDS
